package org.gpp.proj1.test.particle;

import org.gpp.proj1.particle.ParticleFactory;
import org.gpp.proj1.test.testutils.JMETestDisplayManager;

/**
 * 
 * @author Gustavo de Farias
 */
public class ParticleFacade {
	
	/**
	 * 
	 */
	public ParticleFacade() {
		JMETestDisplayManager.initJME();
				
		ParticleFactory.getInstance().createParticle("fire");
		ParticleFactory.getInstance().createParticle("jet");
		ParticleFactory.getInstance().createParticle("smoke");
	}
	
	/**
	 * @param type
	 * @return
	 */
	public String loadType(String type) {
		return type;
	}
	
	/**
	 * @param type
	 * @return
	 */
	public int getParticleNumber(String type) {
		return ParticleFactory.getInstance().createParticle(type).getParticlesNumber();
	}
	
	/**
	 * @param type
	 * @param coordinate
	 * @return
	 */
	public float getGravityForce(String type, String coordinate) {
		
		if (coordinate.toLowerCase().equals("x")) {
			return ParticleFactory.getInstance().createParticle(type).getGravityForce().x;
		}
		else if (coordinate.toLowerCase().equals("y")) {
			return ParticleFactory.getInstance().createParticle(type).getGravityForce().y;
		} 
		else if (coordinate.toLowerCase().equals("z")) {
			return ParticleFactory.getInstance().createParticle(type).getGravityForce().z;
		}
		
		throw new RuntimeException("Invalid coordinate");
	}
	
	/**
	 * @param type
	 * @param coordinate
	 * @return
	 */
	public float getEmissionDirection(String type, String coordinate) {
		
		if (coordinate.toLowerCase().equals("x")) {
			return ParticleFactory.getInstance().createParticle(type).getEmissionDirection().x;
		}
		else if (coordinate.toLowerCase().equals("y")) {
			return ParticleFactory.getInstance().createParticle(type).getEmissionDirection().y;
		} 
		else if (coordinate.toLowerCase().equals("z")) {
			return ParticleFactory.getInstance().createParticle(type).getEmissionDirection().z;
		}
		
		throw new RuntimeException("Invalid coordinate");
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getEmissionMaximumAngle(String type) {
		return ParticleFactory.getInstance().createParticle(type).getEmissionMaximumAngle();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getEmissionMinimumAngle(String type) {
		return ParticleFactory.getInstance().createParticle(type).getEmissionMinimumAngle();
	}

	/**
	 * @param type
	 * @return
	 */
	public float getSpeed(String type) {
		return ParticleFactory.getInstance().createParticle(type).getSpeed();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getParticlesMinimumLifeTime(String type) {
		return ParticleFactory.getInstance().createParticle(type).getParticlesMinimumLifeTime();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getStartSize(String type) {
		return ParticleFactory.getInstance().createParticle(type).getStartSize();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getEndSize(String type) {
		return ParticleFactory.getInstance().createParticle(type).getEndSize();
	}
	
	/**
	 * @param type
	 * @param component
	 * @return
	 */
	public float getStartColor(String type, String component) {
		
		if (component.toLowerCase().equals("r")) {
			return ParticleFactory.getInstance().createParticle(type).getStartColor().r;
		}
		else if (component.toLowerCase().equals("g")) {
			return ParticleFactory.getInstance().createParticle(type).getStartColor().g;
		} 
		else if (component.toLowerCase().equals("b")) {
			return ParticleFactory.getInstance().createParticle(type).getStartColor().b;
		}
		else if (component.toLowerCase().equals("a")) {
			return ParticleFactory.getInstance().createParticle(type).getStartColor().a;
		}
		
		throw new RuntimeException("Invalid color component.");
	}
	
	/**
	 * @param type
	 * @param component
	 * @return
	 */
	public float getEndColor(String type, String component) {
		
		if (component.toLowerCase().equals("r")) {
			return ParticleFactory.getInstance().createParticle(type).getEndColor().r;
		}
		else if (component.toLowerCase().equals("g")) {
			return ParticleFactory.getInstance().createParticle(type).getEndColor().g;
		} 
		else if (component.toLowerCase().equals("b")) {
			return ParticleFactory.getInstance().createParticle(type).getEndColor().b;
		}
		else if (component.toLowerCase().equals("a")) {
			return ParticleFactory.getInstance().createParticle(type).getEndColor().a;
		}
		
		throw new RuntimeException("Invalid color component.");
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getRandomMod(String type) {
		return ParticleFactory.getInstance().createParticle(type).getRandomMod();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public boolean getControlFlow(String type) {
		return ParticleFactory.getInstance().createParticle(type).getControlFlow();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public int getReleaseRate(String type) {
		return ParticleFactory.getInstance().createParticle(type).getReleaseRate();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getReleaseVariance(String type) {
		return ParticleFactory.getInstance().createParticle(type).getReleaseVariance();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getInitialVelocity(String type) {
		return ParticleFactory.getInstance().createParticle(type).getInitialVelocity();
	}
	
	/**
	 * @param type
	 * @return
	 */
	public float getParticleSpinSpeed(String type) {
		return ParticleFactory.getInstance().createParticle(type).getParticleSpinSpeed();
	}
}